home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11353 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: nnrp.info.ucla.edu!usenet
  2. From: mael1@ucla.edu (Matt Waggoner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Null Pointer Assignment
  5. Date: 14 Mar 1996 03:43:09 GMT
  6. Organization: University of California, Los Angeles
  7. Message-ID: <4i84kd$1lh4@saba.info.ucla.edu>
  8. NNTP-Posting-Host: s187_40.resnet.ucla.edu
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.6
  12.  
  13. I have a class called City that contains a private data member, char *name.  
  14. The constructor receives an argument called char *s.  The constructor looks 
  15. like this:
  16.  
  17. City::City(char *s)
  18. {
  19.     name = new char(strlen(s));
  20.     name = s;
  21. }
  22.  
  23. The program works fine, but I get a NULL POINTER ASSIGNMENT whenever it 
  24. terminates.  What the HELL causes this, and how do I get rid of it?  A quick 
  25. answer would be good, I'm under a bit of time pressure... thanks in advance.
  26.  
  27. --------------------------------------------------------------
  28. Matt Waggoner
  29. mael1@ucla.edu
  30. In the beginning, there was nothing, and God said, "Let there 
  31. be light," and there was still nothing, but you could see it.
  32. --------------------------------------------------------------
  33.  
  34.